package cn.springbook.common.core.model;

import cn.springbook.common.core.enums.ResultEnum;

/**
 * <p>
 *
 * </p>
 *
 * @author: caifenglin
 * @date: 2021/7/7 15:22
 */
public class ResponseResultUtil {

    public static <T> ResponseResult<T> success() {
        return ResponseResult.<T>builder().withSuccess(true).withCode(ResultEnum.SUCCESS.getCode()).withMessage(ResultEnum.SUCCESS.getMessage()).build();
    }

    public static <T> ResponseResult<T> success(String msg) {
        return ResponseResult.<T>builder().withSuccess(true).withCode(ResultEnum.SUCCESS.getCode()).withMessage(msg).build();
    }

    public static <T> ResponseResult<T> success(T data) {
        return ResponseResult.<T>builder().withSuccess(true).withCode(ResultEnum.SUCCESS.getCode()).withMessage(ResultEnum.SUCCESS.getMessage()).withData(data).build();
    }

    public static <T> ResponseResult<T> success(String msg, T data) {
        return ResponseResult.<T>builder().withSuccess(true).withCode(ResultEnum.SUCCESS.getCode()).withMessage(msg).withData(data).build();
    }

    public static <T> ResponseResult<T> failure() {
        return ResponseResult.<T>builder().withSuccess(false).withCode(ResultEnum.FAIL.getCode()).withMessage(ResultEnum.FAIL.getMessage()).build();
    }

    public static <T> ResponseResult<T> failure(ResultEnum resultEnum) {
        return ResponseResult.<T>builder().withSuccess(false).withCode(resultEnum.getCode()).withMessage(resultEnum.getMessage()).build();
    }

    public static <T> ResponseResult<T> failure(String message) {
        return ResponseResult.<T>builder().withSuccess(false).withCode(ResultEnum.FAIL.getCode()).withMessage(message).build();
    }

    public static <T> ResponseResult<T> failure(int code, String message) {
        return ResponseResult.<T>builder().withSuccess(false).withCode(code).withMessage(message).build();
    }

    public static <T> ResponseResult<T> failure(ResultEnum resultEnum, T data) {
        return ResponseResult.<T>builder().withSuccess(false).withCode(ResultEnum.FAIL.getCode()).withMessage(ResultEnum.FAIL.getMessage()).withData(data).build();
    }

    public static <T> ResponseResult<T> failure(int code, String message, T data) {
        return ResponseResult.<T>builder().withSuccess(false).withCode(code).withMessage(message).withData(data).build();
    }
}
